<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
</head>
<style>
    .filePicker{
        margin-top: -5px;
        width: 150px;
        height: 44px;
        background: #00A2D4;
        color: #fff;
        text-align: center;
        line-height: 44px;
        border-radius: 4px;
        cursor: pointer;
    }
    .file{
        position: absolute;
        left: 5px;
        top: -5px;
        width: 150px;
        height: 44px;
        line-height: 44px;
        opacity: 0;
        cursor: pointer;
    }
    #myTabContent .img-file{
        width: 100px;
        height: 100px;
        display: block;
        margin-left: 26px;
        margin-top: 10px;
        display: none;
    }
    .fade{
        display: none;
    }
    .fade.active{
        display: block;
    }
</style>
<body>

{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>
                    当前位置是&nbsp;:&nbsp;
                </li>
                <li><a href="javascript:histort.back();">商管理</a></li>
                <li class="active" style="color: #02b87f;">完善信息</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-heading addCharts" style="background:#ededed;">代理商完善信息</div>
            <div class="panel-body">
                <ul id="myTab" class="nav nav-tabs">
                    <li class="active">
                        <a href="#info" data-toggle="tab">基本信息</a>
                    </li>
                    <li>
                        <a href="#dalifs" data-toggle="tab">支付信息</a>
                    </li>
                    <li>
                        <a href="#open" data-toggle="tab">开放平台</a>
                    </li>
                </ul>
                <div id="myTabContent" class="tab-content" style="padding-top:15px;">
                    <form class="form-horizontal adminex-form" action="" method="post" id="tongdao" enctype="multipart/form-data" onsubmit="return sumbitTest();">
                        <div id="info" class="tab-pane fade in active">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">代理商</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="agentname" name="name" value="{$agentinfo.name}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">联系人</label>
                                <div class="col-sm-10">
                                    <input type="text" id="contacts" name="contacts" class="form-control ipt4"  value="{$agentinfo.contacts}">
                                </div>
                            </div>
                            <div class="form-group" >
                                <label class="col-sm-2 col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input type="text" id="tel" name="tel" class="form-control ipt4"  value="{$agentinfo.tel}">
                                </div>
                            </div>

                            <div class="form-group" >
                                <label class="col-sm-2 col-sm-2 control-label">联系地址</label>
                                <div class="col-sm-10">
                                    <input type="text" id="address" name="address" class="form-control ipt4"  value="{$agentinfo.address}">
                                </div>
                            </div>

                        </div>
                        <div id="dalifs" class="tab-pane fade">
                            <ul id="myTab1" class="nav nav-tabs">
                                <li class="active">
                                    <a href="#tab_weixin" data-toggle="tab">微信通道</a>
                                </li>
                                <li>
                                    <a href="#tab_zfb" data-toggle="tab">支付宝通道</a>
                                </li>
                                <li>
                                    <a href="#tab_bank" data-toggle="tab">民生通道</a>
                                </li>
                            </ul>
                            <div id="myTabContent1" class="tab-content" style="padding-top:15px;">
                                <div class="tab-pane fade in active" id="tab_weixin">
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户号</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="partnerid" name="partnerid" class="form-control ipt4" value="{$agentinfo.partnerid}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户密钥</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="partnerkey" name="partnerkey" class="form-control ipt4" value="{$agentinfo.partnerkey}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">上传证书cert</label>
                                        <div class="col-sm-10">
                                            <div class="filePicker  pull-left" id="file0">选择证书</div>
                                            <input type="file" id="val-file0" name="file" class="file" onchange="upload('val-file0')"/>
                                            <input type="hidden" class="file-val-file0" name="apiclient_cert" value="{$agentinfo.apiclient_cert}" />
                                            {empty name="$agentinfo.apiclient_cert"}
                                            <div class="val-file0 pull-left mgl15" style="color: darkred;line-height: 32px;">未上传</div>
                                            {else/}
                                            <div class="val-file0 pull-left mgl15" style="color: green;line-height: 32px;">已上传</div>
                                            {/empty}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">上传证书key</label>
                                        <div class="col-sm-10">
                                            <div class="filePicker pull-left" id="file1">选择证书</div>
                                            <input type="file" id="val-file1" name="file" class="file" onchange="upload('val-file1')"/>
                                            <input type="hidden" class="file-val-file1" name="apiclient_key" value="{$agentinfo.apiclient_key}" />
                                            {empty name="$agentinfo.apiclient_key"}
                                            <div class="val-file1 pull-left mgl15" style="color: darkred;line-height: 32px;">未上传</div>

                                            {else/}
                                            <div class="val-file1 pull-left mgl15" style="color: green;line-height: 32px;">已上传</div>
                                            {/empty}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">上传证书rootca</label>
                                        <div class="col-sm-10">
                                            <div class="filePicker pull-left" id="file2">上传证书</div>
                                            <input type="file" id="val-file2" name="file" class="file" onchange="upload('val-file2')"/>
                                            <input type="hidden" class="file-val-file2" name="rootca" value="{$agentinfo.rootca}" />
                                            {empty name="$agentinfo.rootca"}
                                            <div class="val-file2 pull-left mgl15" style="color: darkred;line-height: 32px;">未上传</div>

                                            {else/}
                                            <div class="val-file2 pull-left mgl15" style="color: green;line-height: 32px;">已上传</div>
                                            {/empty}
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab_zfb">
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">应用ID</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control ipt4" id="ali_app_id" name="ali_app_id" value="{$agentinfo.ali_app_id}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">合作伙伴ID</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="sys_service_provider_id" name="sys_service_provider_id" class="form-control ipt4" value="{$agentinfo.sys_service_provider_id}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">支付宝RAS密钥</label>
                                        <div class="col-sm-10">
                                            <textarea type="text" id="ali_app_key" name="ali_app_key" class="form-control" style="resize: none; width:80%;height:200px;" >{$agentinfo.ali_app_key}</textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab_bank">
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">证书</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="cmmb_mch_id" name="cmmb_mch_id" class="form-control" value="{$agentinfo.cmmb_mch_id}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">密钥key</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="cmmb_key" name="cmmb_key" class="form-control" value="{$agentinfo.cmmb_key}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="open" class="tab-pane fade" style="padding-top:15px;">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">网站域名(不带https)</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="open_url" name="open_url"  value="{$agentinfo.open_url}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">开放平台appid</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="component_appid" name="component_appid"  value="{$agentinfo.component_appid}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">开放平台密钥</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="component_appsecret" name="component_appsecret"  value="{$agentinfo.component_appsecret}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">消息加解密key</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" style="display: inline-block;" id="component_encodingaeskey" name="component_encodingaeskey"  value="{$agentinfo.component_encodingaeskey}" >
                                    <div class="val-file0  mgl15" style="display: inline-block;">
                                        <div onclick="show('component_encodingaeskey',43)">生成</div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">消息校验Token</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" style="display: inline-block;" id="component_token" name="component_token"  value="{$agentinfo.component_token}" >
                                    <div class="val-file0  mgl15" style="display: inline-block;">
                                        <div  onclick="show('component_token',16)">生成</div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">小程序请求信任域名</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="requestdomain" name="requestdomain"  value="{$agentinfo.requestdomain}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">小程序通信信任域名</label>
                                <div class="col-sm-10">
                                    <input type="text" id="wsrequestdomain" name="wsrequestdomain" class="form-control ipt4"  value="{$agentinfo.wsrequestdomain}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">小程序上传信任域名</label>
                                <div class="col-sm-10">
                                    <input type="text" id="uploaddomain" name="uploaddomain" class="form-control ipt4"  value="{$agentinfo.uploaddomain}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">小程序下载信任域名</label>
                                <div class="col-sm-10">
                                    <input type="text" id="downloaddomain" name="downloaddomain" class="form-control ipt4"  value="{$agentinfo.downloaddomain}">
                                </div>
                            </div>
                            <div class="form-group" >
                                <label class="col-sm-2 col-sm-2 control-label"> 小程序网关信任域名</label>
                                <div class="col-sm-10">
                                    <input type="text" id="webviewdomain" name="webviewdomain" class="form-control ipt4"  value="{$agentinfo.webviewdomain}">
                                </div>
                            </div>

                        </div>
                        <div style="text-align: center">
                            <button type="submit" class="btn btn-primary">确认提交</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
        {include file='public/footer'/}

    </div>
</section>
<script src="__STATIC_URL__/static/layer/layer.js"></script>
<script>

</script>
<script>
    function show(type,nums) {


        $.ajax({
            url: "{:url('Agents/generate_rand')}",
            type: 'POST',
            cache: false,
            dataType: "json",
            data: {
                num: nums

            },
            success: function (data) {
                //console.log(data);
                $('#' + type).val(data);

            }

        });

    }
</script>
<script>
    function upload(file) {
        //检验图片格式
        var filename = $("#"+file).val();
        var patterArr = ['pem'];
        var strTip = "上传";
        if (filename == "") {
            alert("请先选择需要" + strTip + "的文件");
            return false;
        } else {
            var patter = eval("/(" + patterArr.join("|") + ")/");
            if (!patter.test(filename.substring(filename.lastIndexOf("."), filename.length).toLowerCase())) {
                alert("请选择后缀名为" + patterArr.join(",") + "的文件" + strTip);
                $("#"+file).val("");
                return false;
            }
            //文件上传
            var formData = new FormData();
            formData.append('file', $('#' + file)[0].files[0]);
            $.ajax({
                url: "{:url('uploads/uploadpem')}",
                type: 'POST',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                beforeSend:function(){
                    //加载层
                    index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                },
                success:function (res) {
                    layer.close(index);
                    if(res.url!=""){
                        $("."+file).css("color","red").text("上传成功");
                        $(".file-"+file).val(res.url);
                    }else{
                        $("."+file).css("color","red").text("上传失败");
                    }
                },
                error:function(e){
                    layer.close(index);
                    alert("上传失败")
                }
            })
        }

    }
</script>
</body>
</html>
